[deps]
musl
kernel-headers

[vars]
filesize=1045868
sha512=38108a94118b56c6f3982e692beb1068c52f9aecd74447d6b552b77fae5e365eab72b4781bdf07d9696ac89d54371c1cae8cc0363de510b53988302acef50dba

[mirrors]
http://dl.suckless.org/tools/9base-6.tar.gz

[build]
mbwc_fix() {
        local file=$1
        echo '#include "mbwc.h"' > $file
        cat troff/$file >> $file
        mv $file troff/$file
}
for i in n1.c t11.c n10.c mbwc.c ; do mbwc_fix $i ; done

echo "PREFIX = /local/plan9" >>config.mk
# the dc calculator, called by bc, assumes a signed char,
# which is not true for ARM. it fails on "4 - 3" resp. "4 3 -ps."
# without -fsigned-char.
echo "CFLAGS += -fsigned-char -D_GNU_SOURCE -DPLAN9PORT -D__USE_MISC $optcflags" >>config.mk
echo "LDFLAGS += $optldflags" >> config.mk

sed -i 's/__linux__/__not_linux__/;s/__sun__/__linux__/' lib9/dirread.c
sed -i '/sys.termios.h/d' lib9/readcons.c
sed -i '/^.touch./d' Makefile  # we don't have futimes

# ed's getline clobbers the one defined in musl, and this causes problems
# when libc functions like getpwuid call getline.
patch -p1 < "$K"/9base-ed-getline.patch
make -j$MAKE_THREADS install

exit 0


